package com.example.springbootdemo;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author brianxia
 * @version 1.0
 * @date 2022-11-07 14:11
 */
@RestController //标记Controller层可以编写接口，返回结果是json数据
//@Controller
public class TestController {

    @GetMapping("/test")
    //@ResponseBody
    public Result test() {
        getException();

        Result result = new Result();
        result.setMsg("成功");
        result.setCode(1000);
        return result;

    }

    private void getException() {
        throw new MyException("测试一下自定义异常", 4000);
    }
}
